$(document).ready(function () {

    $('#errBox').hide();

    $('#btnLogin').bind('click',btnLoginClick);
})

function btnLoginClick(){

    $.ajax({
         url:'http://test.org/add',
         method:'post',
         dataType:'json',
         success:function (data) {

          var current=    data.find(function (user) { // 按规则查找
                  return user.username == $('#username').val()&& user.password ==$('#password').val();
              })

             if(current){
                window.location.href="index.html";
             }else {
                $('#errBox').show();
             }
         }


    })

}